//
//  S1mpl3HotListenHeadCollectionViewCell.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/7.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "S1mpl3HotListenHeadCollectionViewCell.h"
#import "FitHeader.h"
#import "UIImageView+WebCache.h"

@implementation S1mpl3HotListenHeadCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatView];
    }
    return self;
}

-(void)creatView{
    _leftImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_leftImageView];
    
    _titleLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    
    _leftLineLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_leftLineLabel];
    
    _descriptionLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_descriptionLabel];
    
    _rightLineLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightLineLabel];
    
    _contentLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_contentLabel];
    
    _baseLeftLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_baseLeftLabel];
    
    _baseCenterImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_baseCenterImageView];
    
    _baseRightLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:_baseRightLabel];
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    _leftImageView.frame = CGRectMake(10 * FITWidth, 20 * FITHeight, 40 * FITHeight, 40 * FITHeight);
    _titleLabel.frame = CGRectMake(_leftImageView.frame.origin.x + _leftImageView.frame.size.width, 10 * FITHeight, 320 * FITWidth, 50 * FITHeight);
    _titleLabel.numberOfLines = 0;
    
    _leftLineLabel.frame = CGRectMake(80 * FITWidth, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 20 * FITHeight, 75 * FITWidth, 1 * FITHeight);
    _leftLineLabel.backgroundColor = [UIColor lightGrayColor];
    _descriptionLabel.frame = CGRectMake(_leftLineLabel.frame.origin.x + _leftLineLabel.frame.size.width + 5 * FITWidth, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 10 * FITHeight, 60 * FITWidth, 20 * FITHeight);
    _descriptionLabel.text = @"简介";
    _descriptionLabel.textAlignment = 1;
    _descriptionLabel.textColor = [UIColor lightGrayColor];
    
    _rightLineLabel.frame = CGRectMake(_descriptionLabel.frame.origin.x + _descriptionLabel.frame.size.width + 5 * FITWidth, _leftLineLabel.frame.origin.y, _leftLineLabel.frame.size.width, _leftLineLabel.frame.size.height);
    _rightLineLabel.backgroundColor = [UIColor lightGrayColor];
    
    _contentLabel.font = [UIFont systemFontOfSize:16];
    _contentLabel.numberOfLines = 0;
    
    _contentLabel.frame = CGRectMake(_leftImageView.frame.origin.x, _descriptionLabel.frame.origin.y + _descriptionLabel.frame.size.height, 355 * FITWidth, 0);
//    [_contentLabel setFontSize:12];
    _baseLeftLabel.frame = CGRectMake(280 * FITWidth, _contentLabel.frame.origin.y + _contentLabel.frame.size.height + 5 * FITHeight, 30 * FITWidth, 15 * FITHeight);
    
    _baseLeftLabel.text = @"小编";
    [_baseLeftLabel setFontSize:14];
    _baseCenterImageView.frame = CGRectMake(_baseLeftLabel.frame.origin.x + _baseLeftLabel.frame.size.width, _baseLeftLabel.frame.origin.y , 16 * FITHeight, 16 * FITHeight);
    _baseCenterImageView.layer.cornerRadius = 8 * FITHeight;
    _baseRightLabel.frame = CGRectMake(_baseCenterImageView.frame.origin.x + _baseCenterImageView.frame.size.width, _baseLeftLabel.frame.origin.y , 50 * FITWidth, _baseLeftLabel.frame.size.height);
    [_baseRightLabel setFontSize:14];
}

-(void)setHotListenHead:(S1mpl3HotListenHead *)hotListenHead{
    if (_hotListenHead != hotListenHead) {
        _hotListenHead = hotListenHead;
    }
    CGRect rect = [_hotListenHead.intro boundingRectWithSize:CGSizeMake(355 * FITWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:16], NSFontAttributeName, nil] context:nil];
    _contentLabel.frame = CGRectMake(_leftImageView.frame.origin.x, _descriptionLabel.frame.origin.y + _descriptionLabel.frame.size.height, 355 * FITWidth, ceill(rect.size.height + 1));
//    [_contentLabel setFontSize:16];
    _baseLeftLabel.frame = CGRectMake(260 * FITWidth, _contentLabel.frame.origin.y + _contentLabel.frame.size.height + 5 * FITHeight, 30 * FITWidth, 15 * FITHeight);
    
    
    _baseCenterImageView.frame = CGRectMake(_baseLeftLabel.frame.origin.x + _baseLeftLabel.frame.size.width + 5 * FITWidth, _baseLeftLabel.frame.origin.y , 16 * FITHeight, 16 * FITHeight);
    _baseRightLabel.frame = CGRectMake(_baseCenterImageView.frame.origin.x + _baseCenterImageView.frame.size.width + 5 * FITWidth, _baseLeftLabel.frame.origin.y , 50 * FITWidth, _baseLeftLabel.frame.size.height);

    _titleLabel.text = hotListenHead.title;
    _contentLabel.text = hotListenHead.intro;
    _baseCenterImageView.layer.masksToBounds = YES;
    [_baseCenterImageView sd_setImageWithURL:[NSURL URLWithString:hotListenHead.smallLogo] placeholderImage:[UIImage imageNamed:@"100*100"]];
    _baseRightLabel.text = _hotListenHead.nickname;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
